'''
Created on 2009-10-22

@author: summit
'''
import itk
from enthought.traits import api as traits
from enthought.traits.ui import api as traitsui
from jolly.tvisual.titkbase import *

class BinaryThresholdSegmentation(titkbase):
    '''
    classdocs
    '''
    
    
    def __init__(self, IType, OType, obj=None, update=True, **traits):
        titkbase.__init__(self, itk.BinaryThresholdImageFilter[IType, OType], obj, update, **traits)
      
    
    def _get_input(self):
        return self._obj.GetInput ()
    def _set_input(self, arg):
        old_val = self._get_input()
        self._obj.SetInput(arg)
        self.trait_property_changed('set_input', old_val, deref_itk(arg))
    input = traits.Property(_get_input, _set_input, help=\
        '''
        Set input image
        '''
    )
    def _get_lower_threshold(self):
        return self._obj.GetLowerThreshold()
    def _set_lower_threshold(self, arg):
        old_val = self._get_lower_threshold()
        if arg<>"" and float(arg)<itk.range(self.input)[0] and float(arg)>itk.range(self.input)[1]:
            self._obj.SetLowerThreshold(float(arg))
            self.trait_property_changed('lower_threshold', old_val, deref_itk(arg))
    lower_threshold = traits.Property(_get_lower_threshold, _set_lower_threshold, traits=traits.Float(0.0), help=\
        """
        Get the internal lower threshold.
        """
    )
    
    
if __name__=="__main__":
    x = itk.BinaryThresholdImageFilter[itk.Image[itk.US, 2], itk.Image[itk.US, 2]].New()
    y = itk.Image[itk.US, 2].New()
    x.SetInput(y)
    BinaryThresholdSegmentation(itk.Image[itk.US, 2], itk.Image[itk.US, 2],x).configure_traits()